import java.util.Scanner;

public class MenPai {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        for(int i = 1;i<=2020;i++){
            int ret = i;
            while(ret != 0){
                if(ret%10 == 2){
                    count++;
                }
                ret /= 10;
            }
        }
        System.out.println(count);
        scan.close();
    }
}
